package gov.fema.hazus.bdc.client.controller;

public class Controller {

	public final static String MAIN_SHOW_BUILDING_LIST = "/main/show/building/list";
	public final static String MAIN_SHOW_SETTINGS = "/main/show/settings";
	public final static String MAIN_SHOW_BUILDING_EDITOR = "/main/show/building/editor";
	
	public final static String BUILDINGLIST_GET_BUILDINGS = "/buildinglist/get/buildings";
	public final static String LOGIN = "/incast/login";
	public final static String LOGOUT = "/incast/logout";
	
	
    private static Controller singleton;
	
    public static Controller get()
    {
        if( singleton == null )
        {
            singleton = new Controller();
        }
        return singleton;
    }
    
    public Controller()
    {

    }
    
    public void hideUI()
    {
    	buildingEditorSetVisible(false);
    	mapSetVisible(false);
    }

    public native void mainLogin() /*-{
		@gov.fema.hazus.bdc.client.MainUI::actionWrapperLogin()();
	}-*/;  

    public native void mainLogout() /*-{
		@gov.fema.hazus.bdc.client.MainUI::actionWrapperLogout()();
	}-*/;  
    
    public native void mainShowBuildingEditor() /*-{
		@gov.fema.hazus.bdc.client.MainUI::actionWrapperShowBuildingEditor()()
	}-*/;
    
    public native void mainShowBuildingList() /*-{
    	@gov.fema.hazus.bdc.client.MainUI::actionWrapperShowBuildingList()()
    }-*/;
    
    public native void mainShowBuildingMap() /*-{
		@gov.fema.hazus.bdc.client.MainUI::actionWrapperShowBuildingMap()()
	}-*/;  
    
    public native void mainShowLoginPage() /*-{
		@gov.fema.hazus.bdc.client.MainUI::actionWrapperShowLoginPage()()
	}-*/;
    
    public native void mainShowSettings() /*-{
		@gov.fema.hazus.bdc.client.MainUI::actionWrapperShowSettings()()
	}-*/;    
    
    public native void mainShowUserEditor() /*-{
	@gov.fema.hazus.bdc.client.MainUI::actionWrapperShowUserEditor()()
	}-*/;
    
    public native void mainShowUserList() /*-{
	@gov.fema.hazus.bdc.client.MainUI::actionWrapperShowUserList()()
	}-*/;

    public native void buildingListGetBuildings() /*-{
		@gov.fema.hazus.bdc.client.settings.Settings::actionWrapperHide()();
		@gov.fema.hazus.bdc.client.ui.BuildingList::actionWrapperGetBuildings()();
	}-*/;     
    
    public native void buildingListResetAndExecuteSearch() /*-{
    	@gov.fema.hazus.bdc.client.ui.BuildingList::actionWrapperResetAndExecuteSearch()();
    }-*/;
	
    public native int getLeftNavigationWidth() /*-{
		return @gov.fema.hazus.bdc.client.ui.LeftNavigation::propertyGetWidth()();
	}-*/;

    public native int getRightNavigationWidth() /*-{
		return @gov.fema.hazus.bdc.client.ui.RightNavigation::propertyGetWidth()();
	}-*/;

    public native int getMainUINorthHeight() /*-{
		return @gov.fema.hazus.bdc.client.MainUI::propertyGetMainUINorthHeight()();
	}-*/;

	public native void showLoginPage() /*-{
		// Map.get().setVisible(false);
		// MainUI.get().setVisible(false);
		// Login.get().setVisible(true);
	}-*/;
	
	/*--------------  Building Editor Delegators   ------------------*/

    public native void buildingEditorSetVisible(boolean flag) /*-{
		@gov.fema.hazus.bdc.client.ui.BuildingEditor::actionWrapperSetVisible(Z)(flag);
	}-*/;
    
    public native void buildingEditorAddBuilding() /*-{
		@gov.fema.hazus.bdc.client.ui.BuildingEditor::actionWrapperAddBuilding()();
	}-*/;

	public native double buildingEditorGetBuildingLatitude() /*-{
		return @gov.fema.hazus.bdc.client.ui.BuildingEditor::actionWrapperGetBuildingLatitude()();
	}-*/;
	
	public native double buildingEditorGetBuildingLongitude() /*-{
		return @gov.fema.hazus.bdc.client.ui.BuildingEditor::actionWrapperGetBuildingLongitude()();
	}-*/;
	
	public native void buildingEditorUpdateLatLng(double latitude, double longitude) /*-{
		@gov.fema.hazus.bdc.client.ui.BuildingEditor::actionWrapperUpdateLatLng(DD)(latitude, longitude);
	}-*/;
	
	
	
	/*--------------  Map Delegators   ------------------*/
	
	/*
	 * These delegators go to the default map that is packaged with InCAST Web, which is
	 * the @gov.fema.riskmap.assessment.hazus.incast.map.client.Map
	 * 
	 * To extend the feature set of map, you may edit the Map class listed above, or create
	 * a new class implementing MapInterface. When your new class is ready to be integrated
	 * with InCAST, change the delegated JSNI methods below to those in your own class.
	 * 
	 */
	
	public native void mapSetVisible(boolean flag) /*-{
		@gov.fema.hazus.bdc.client.map.Map::actionWrapperSetVisible(Z)(flag);
	}-*/;	
	
	public native void mapResize(int width, int height) /*-{
		@gov.fema.hazus.bdc.client.map.Map::actionWrapperMapResize(II)(width, height);
	}-*/;
	
	public native void mapGetBuildings() /*-{
		@gov.fema.hazus.bdc.client.map.Map::actionWrapperGetBuildings()();
	}-*/;

	/*--------------  Settings Delegators   ------------------*/
	
	/*
	 * These delegators go to the settings view that is packaged with InCAST Web, which is
	 * the @gov.fema.hazus.bdc.client.settings.Settings.
	 *
	 * 
	 */


}
